$(function(){
	//获取头条列表以及一级类别列表的url
	var url = "/o2oSystem/frontend/listmainpageinfo";
	//访问后台请求
	$.getJSON(url,function(data){
		if(data.success){
			//获取后台传来的头条列表
			var headLineList = data.headLineList;
			var swiperHtml = "";
			//遍历头条列表，拼接出轮播图组
			headLineList.map(function(item,index){
				swiperHtml += "<div class='swiper-slide img-wrap'>" +
				"<a href='"+item.lineLink+"' external>" +
				"<img class='banner-img' src='"+item.lineImg+"' " +
				"alt='"+item.lineName+"'></img></a></div>";
			});
			//将轮播图组赋值给前端Html控件
			$(".swiper-wrapper").html(swiperHtml);
			//设定轮播图轮换时间为3秒
			$(".swiper-container").swiper({
				autoplay:3000,
				//用户对轮播图进行操作时，是否自动停止autoplay
				autoplayDisableOnInteration:false
			});
			//获取后台传过来的大类列表，拼接两个一行的列表
			var shopCategoryList = data.shopCategoryList;
			var categoryHtml = "";
			shopCategoryList.map(function(item,index){
				categoryHtml +="<div class='col-50 shop-classify' data-category='"+item.shopCategoryId+"'>" +
				"<div class='word' ><p class='shop-title'>"+item.shopCategoryName+"</p>" +
				"<p class='shop-desc' >"+item.shopCategoryDesc+"</p></div>" +
				"<div class='shop-classify-img-warp'>" +
				"<img class='shop-img' src='"+item.shopCategoryImg+"'></img></div></div>";
			});
			//将拼接好的类别赋值给前端html控件展示
			$(".row").html(categoryHtml);
		}
	});
	//点击 我  显示侧栏
	$("#me").click(function(){
		$.openPanel("#panel-right-demo");
	});
	//给大类别绑定点击事件
	$(".row").on("click",".shop-classify",function(e){
		var shopCategoryId = e.currentTarget.dataset.category;
		var newUrl = "/o2oSystem/frontend/shoplist?parentId="+shopCategoryId;
		window.location.href = newUrl;
	});
})